import React, { useState } from 'react'
import {useSelector,useDispatch} from 'react-redux'
import {addAge,setName} from '../redux/actions/homeAction'
function Home() {
   let dispatch = useDispatch();
   let homeState = useSelector((state)=>{
      console.log(state)
      return state.homeReducer
   })
   let {name,age} = homeState;
    return (
      <div>
            <div>Home</div>
            <h1>{name}---{age}</h1>
            <button onClick={()=>{
              dispatch(addAge(5))
            }}>++</button>
            <button onClick={()=>{
              dispatch(setName("李四"))
            }}>换人</button>
      </div>
    )
  }
export default Home
